home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 March / PCWorld_2002-03_cd.bin / Software / TemaCD / mspowertoys / Microsoft PowerToys for Windows XP_files / global.js < prev    next >
Text File  |  2001-11-05  |  9KB  |  365 lines

  1.     var shadows = new Array();
  2.     var menu;
  3.     var timerId = 0;
  4.     var timerDelId = 0;
  5.     //used for the change_display(head) function
  6.     var sImgExpandedArrow = "";    
  7.     var sImgDefaultArrow = "";
  8.  
  9.  
  10.     function deletePopup() {
  11.         if (menu) {
  12.             menu.style.display = 'none';
  13.             var selects = document.all.tags("SELECT");
  14.             if (selects!=null) {
  15.                 for (var i=0; i<selects.length; i++) {
  16.                     selects[i].style.visibility = 'visible';
  17.                 }
  18.             }
  19.         }
  20.     }
  21.     function doMenuz(el, popup) {
  22.         timerId = 0;
  23.         if (menu) {
  24.             deletePopup();
  25.         }
  26.         var selects = document.all.tags("SELECT");
  27.         if (selects!=null) {
  28.             for (var i=0; i<selects.length; i++)
  29.             {
  30.                 selects[i].style.visibility = 'hidden';
  31.             }
  32.         }
  33.         menu = popup;
  34.         menu.style.posTop = absTop(el);
  35.         
  36.         
  37.         menu.style.posLeft = 177;
  38.         menu.style.display = '';
  39.         menu.style.zIndex = 4;
  40.         menu.onchange = adjustTop(el, popup)
  41.             
  42.     }
  43.     
  44.     function adjustTop(){
  45.         if ((menu.style.posTop+menu.clientHeight) >= document.body.clientHeight) //below bottom
  46.         {
  47.             menu.style.posTop = (menu.style.posTop-(menu.clientHeight)+18);
  48.         } 
  49.         menu.onchange = adjustBottom()
  50.     }
  51.     
  52.     function adjustBottom() {
  53.         if (menu.style.posTop < document.body.scrollTop) //above top
  54.         {
  55.             menu.style.posTop = document.body.scrollTop;
  56.         }
  57.     }
  58.     
  59.     function removePopup() {
  60.         cancelPopup();
  61.         deletePopup();
  62.     }
  63.     function absTop(el) { //finds the top
  64.         var n = el.offsetTop;
  65.         
  66.         while (el.parentElement) {
  67.             el = el.parentElement;
  68.             n += el.offsetTop;
  69.         }
  70.         return n;
  71.     }
  72.     function popup(el) {
  73.         cancelPopup();
  74.         timerId = window.setTimeout('doMenuz(' + el.id + ', ' + el.submenu + ')', 200);
  75.     }
  76.     function cancelPopup() {
  77.         if (timerId != 0) {
  78.             window.clearTimeout(timerId);
  79.             timerId = 0;
  80.         }
  81.     }
  82.     function delayRemove() {
  83.         timerDelId = window.setTimeout('deletePopup()', 200);
  84.     }
  85.     function cancelDelay() {
  86.         if (timerDelId != 0) {
  87.             window.clearTimeout(timerDelId);
  88.             timerDelId = 0;
  89.         }
  90.     }
  91.  
  92.     function rollon(a) {
  93.         a.style.backgroundColor='#CCCCCC';
  94.         a.style.border = '#999999 solid 1px';
  95.     }
  96.  
  97.     function rolloff(a) {
  98.         if (a.className == 'menuBarSel') {
  99.             a.style.backgroundColor='#FFFFFF'
  100.         }
  101.         else {
  102.             a.style.backgroundColor='#f1f1f1';
  103.             a.style.border = '#f1f1f1 solid 1px';
  104.         }
  105.     }
  106.     // added by atilab, works with the 'In This Article' component
  107.     
  108.     
  109.     function change_display(head) {
  110.         var oSrcEle = window.event.srcElement
  111.         sImg666 = oSrcEle.src
  112.  
  113.         if (sImgExpandedArrow == ""){
  114.             sImgExpandedArrow = "/products/shared/images/arrow_expand.gif";    
  115.         }
  116.         if (sImgDefaultArrow == ""){
  117.             sImgDefaultArrow = "/products/shared/images/arrow_default.gif";
  118.         }
  119.         if (document.all.item(head).style.display == "") 
  120.         {
  121.             document.all.item(head).style.display = "none";
  122.             oSrcEle.src = sImgExpandedArrow;
  123.             oSrcEle.alt = "expand menu";
  124.         }
  125.         else 
  126.         {
  127.             document.all.item(head).style.display= "";
  128.             oSrcEle.src = sImgDefaultArrow;
  129.             oSrcEle.alt = "collapse menu";
  130.         }
  131.     }
  132.  
  133.     function chngColour(sID)
  134.         {
  135.         var oMainBorder = document.all.item("main" + sID);
  136.         var oHeaderBorder = document.all.item("header" + sID);
  137.         var oArticle = document.all.item("article" + sID);
  138.         var oArrowCol = document.all.item("arrowCol" + sID);
  139.             if (oMainBorder.className == 'componentBorder')
  140.                 {
  141.                     oMainBorder.className = 'componentBorderSel';
  142.                     oHeaderBorder.className = 'componentBorderSel';
  143.                     oArticle.className = 'componentHeaderSel';
  144.                     oArrowCol.className = 'componentHeaderSel';
  145.                 }
  146.             else
  147.                 {
  148.                     oMainBorder.className = 'componentBorder';
  149.                     oHeaderBorder.className = 'componentBorder';
  150.                     oArticle.className = 'componentHeader';
  151.                     oArrowCol.className = 'componentHeader';                
  152.                 }
  153.         }
  154.  
  155.     function noPrint()
  156.     {
  157.          var noprint = document.all.item("donotprint");
  158.          if (noprint != null)
  159.             if (backicon.style.display != "")
  160.                     {
  161.                          if (noprint.length != null)
  162.                               {
  163.                                   for (var i=0; i<noprint.length; i++)
  164.                                         {
  165.                                              noprint(i).style.display = "none";
  166.                                         }
  167.                                    toggleImgDisplay("/flyout_arrow.gif");//hides flyout arrows
  168.                                    printicon.style.display = "none";
  169.                                    backicon.style.display = "";
  170.                                    document.body.scrollTop = 0; 
  171.                               }
  172.                     }
  173.             else
  174.                     {
  175.                          if (noprint.length != null)
  176.                               {
  177.                               
  178.                                    for (var i=0; i<noprint.length; i++)
  179.                                         {
  180.                                              noprint(i).style.display = "";
  181.                                         }
  182.                                    toggleImgDisplay("/flyout_arrow.gif");//displays flyout arrows
  183.                                    printicon.style.display = "";
  184.                                    backicon.style.display = "none";
  185.                                    document.body.scrollTop = 0; 
  186.                               }
  187.                     }
  188.      }
  189.     
  190.     function toggleImgDisplay(sImgName)
  191.     {
  192.         var oImages = document.images;
  193.         if (oImages != null)
  194.         {
  195.             var iImgLength = oImages.length;
  196.             for (var i=0; i<iImgLength; i++)
  197.             {
  198.                 if (oImages[i].src.indexOf(sImgName)!=-1)
  199.                 {
  200.                     if (oImages[i].style.display=="none")
  201.                     {
  202.                         oImages[i].style.display="";
  203.                     }
  204.                     else
  205.                     {
  206.                         oImages[i].style.display="none";
  207.                     }
  208.                 }
  209.             }
  210.         }        
  211.     }
  212.      
  213.     function togglefaq()
  214.      {
  215.          if (toggle.checked == true){
  216.              expandfaq();
  217.              }
  218.          else{
  219.              contractfaq();
  220.              }
  221.      }
  222.     
  223.     function expandfaq()
  224.     {
  225.          var faqitem = document.all.item("faqitem");
  226.          if (faqitem != null){
  227.                     if (faqitem.length != null){
  228.                               for (i=0; i<faqitem.length; i++){
  229.                                         faqitem(i).style.display = "inline";                                                                               
  230.                                    }                                 
  231.                     }                                            
  232.           }
  233.      }
  234.      
  235.         function contractfaq()
  236.     {
  237.          var faqitem = document.all.item("faqitem");
  238.          var faq = document.all.item("faq");
  239.          if (faq != null){
  240.          for (i=0; i<faq.length; i++){
  241.                                         faq(i).style.color = "#666666";                                                                               
  242.                                    }
  243.          }
  244.          if (faqitem != null){
  245.                     if (faqitem.length != null){
  246.                               for (i=0; i<faqitem.length; i++){
  247.                                         faqitem(i).style.display = "none";                                                                               
  248.                                    }                                 
  249.                     }                                            
  250.           }
  251.      }
  252.      
  253.      function getPar(o) 
  254.      {
  255.       var ele = new Object();
  256.       ele = findDIV(o)
  257.         if (ele!=null)
  258.         {
  259.             var oA = ele.children.item(1);
  260.             if (oA.style.display == "inline")
  261.             {
  262.                 oA.style.display = "none";
  263.                 o.style.color = "#666666";
  264.             }
  265.             else
  266.             {
  267.                 oA.style.display = "inline";
  268.                 
  269.             } 
  270.         }
  271.  
  272.     }
  273.  
  274.     function findDIV(x)
  275.     {
  276.     var oDiv = document.all.tags("DIV");
  277.     var iDiv;
  278.         if (oDiv != null)
  279.         {
  280.             iDiv = oDiv.length;
  281.             for (var i=0; i<iDiv; i++)
  282.             {
  283.                 if(oDiv[i].contains(x))
  284.                 {
  285.                 return oDiv[i];
  286.                 }
  287.             }
  288.         }
  289.     }
  290.     
  291.     function overState(obj)
  292.     {
  293.         obj.currentColor = obj.style.color;
  294.         obj.style.color = "#0033FF";
  295.         obj.style.cursor = "hand";
  296.     }
  297.  
  298.     function outState(obj)
  299.     {
  300.         if ("#0033ff" == obj.style.color)
  301.         {
  302.             obj.style.color = obj.currentColor;
  303.         }
  304.     }
  305.     
  306.         function fnSaveInput(oElement, oBehaviourVar)
  307.     {
  308.         var tExpireTime = new Date();
  309.             tExpireTime.setUTCFullYear(2059,12,31);
  310.             document.all.d1.expires = tExpireTime.toUTCString();
  311.             document.all.d1.setAttribute(oBehaviourVar,oElement.value);
  312.         try 
  313.         {
  314.             document.all.d1.save("oXMLBranch");
  315.         }
  316.         catch(e)
  317.         {
  318.             return e;
  319.         }
  320.     }
  321.  
  322.     function fnLoadInput(oElement, oBehaviourVar)
  323.     {
  324.         try 
  325.         {
  326.             document.all.d1.load("oXMLBranch")
  327.         }
  328.         catch(e)
  329.         {
  330.             return e;
  331.         }
  332.         try
  333.         {
  334.         var s = document.all.d1.getAttribute(oBehaviourVar);
  335.         var i = 0;
  336.             if (s)
  337.             {
  338.                 for (children in oElement)
  339.                 {
  340.                     if (oElement.options(i).value == s) 
  341.                     {
  342.                         oElement.options(i).selected = true;
  343.                         return;
  344.                     }
  345.                      i++;
  346.                 }
  347.             }
  348.         }
  349.         catch(e)
  350.         {
  351.             return e;
  352.         }
  353.     }
  354.     
  355.     function popItUp(page)
  356.     {
  357.       if (page != "")
  358.       {
  359.        popUpWin = window.open(page,"PopUp","toolbar=no,location=0,directories=0,status=no,menubar=no,scrollbars,resizable=no,width=660,height=390");
  360.        popUpWin.focus();
  361.        return false;
  362.       }
  363.     }
  364.  
  365.